/*
 * commons is a based project implemented
 * Copyright (C) 2024 Jasmine
 */
package com.commons.redis.anno;

import java.lang.annotation.*;
import java.util.concurrent.TimeUnit;

/**
 * 使用方法： <br/>
 * eg: @RepeatSubmitLimit(businessKey = "order", expire = 1000) <br/>
 * eg: @RepeatSubmitLimit(businessKey = "order", businessParam = "#name", expire = 1000) <br/>
 * eg: @RepeatSubmitLimit(businessKey = "order", businessParam = "#name", expire = 1000, userLimit = false) <br/>
 * eg: @RepeatSubmitLimit(businessKey = "smsSend", userLimit = false, businessParam = "#smsDTO.phone", expire = 30)
 * public Boolean smsSend(@RequestBody @Validated SmsDTO smsDTO) {
 *
 * @author Jasmine
 * @version 1.0
 * @date 2021-12-13 15:32:32
 * @see RepeatSubmitLimit
 * @since JDK17
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface RepeatSubmitLimit {
    /**
     * 业务key，例如下单业务 order
     */
    String businessKey();

    /**
     * 业务参数，用于做更细粒度锁，例如锁到具体 订单id #orderId 支持Spel
     */
    String businessParam() default "";

    /**
     * redis锁过期时间 默认5s
     */
    int expire() default 5;

    /**
     * redis锁过期时间单位,默认秒
     */
    TimeUnit timeUnit() default TimeUnit.SECONDS;

    /**
     * 是否用户隔离，默认启用
     */
    boolean userLimit() default true;
}